home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.demo_apps;
-
- import sub_arctic.lib.*;
- import sub_arctic.output.*;
- import sub_arctic.input.*;
- import sub_arctic.constraints.std_function;
-
- /* grid.java
- * This is a very simple grid container. All elements must be filled in, and
- * they must be filled in order starting from 0,0.
- *
- * 9/24/96 Colleen Kehoe
- *
- */
-
- public class grid extends shrink_wrap_container {
-
- interactor[][] elements;
- int rows;
- int columns;
-
- public grid(int r, int c) {
- super(0,0,2,true);
- rows = r;
- columns = c;
- elements = new interactor[rows][columns];
- }
-
- public interactor element_at(int i, int j) {
- return elements[i][j];
- }
-
- public void set_element_at(int i, int j, interactor n) {
- elements[i][j] = n;
-
-
- // If we're not in the first column, set our x to be the maximum of the right
- // edge (X2) of the element to our left and the left edge (X1) of the element
- // above us. Similarly for our y value if we're not in the first row.
- if (i != 0 && j != 0) {
- elements[i][j].set_x_constraint(std_function.max(OTHER.OBJ(elements[i][j-1]).X2(),OTHER.OBJ(elements[i-1][j]).X1(),0));
- elements[i][j].set_y_constraint(std_function.max(OTHER.OBJ(elements[i-1][j]).Y2(),OTHER.OBJ(elements[i][j-1]).Y1(),0));
-
- } else {
-
- // If we are in the first column, set our x to our parent's left edge.
- // Otherwise, set it to the right edge of the element to our left.
- if (j == 0) {
- elements[i][j].set_x_constraint(std_function.eq(PARENT.X1()));
- } else {
- elements[i][j].set_x_constraint(std_function.eq(OTHER.OBJ(elements[i][j-1]).X2()));
- }
-
- // If we are in the first row, set our y to our parent's top edge.
- // Otherwise, set it to the bottom edge of the element above us.
- if (i == 0) {
- elements[i][j].set_y_constraint(std_function.eq(PARENT.Y1()));
- } else {
- elements[i][j].set_y_constraint(std_function.eq(OTHER.OBJ(elements[i-1][j]).Y2()));
-
- }
- }
- add_child(elements[i][j]);
- }
-
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-